package com.cherrish.demo.bio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.Charset;

/**
 * @author cherrish
 * @time 2019-02-25 11:13
 * @name BServer
 * @desc:
 */
public class BServer {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9010);
            Socket socket = serverSocket.accept();
            System.out.println(socket.getInetAddress() + "connected");
            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), Charset.forName("UTF-8")));
            String msg = null;
            while (null != (msg = reader.readLine())){
                System.out.println(msg);
            }
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
